﻿<h1>Cart</h1>

<table class="table table-striped">
    <thead>
        <tr class="header">
            <th>&nbsp;</th>
            <th>Product</th>
            <th>Description / SKU</th>
            <th>Stock.</th>
            <th>Price</th> 
            <th>Quantity</th>
            <th>Line Total</th> 
        </tr>
    </thead>    
    <tbody>
		<tr ng-repeat="item in cart.Items">
            <td>
                <button ng-click="cart.deleteItem($index)" class="btn">delete</button>
            </td>
            <td>
				<a href="/#!/product/{{item.Product.Code}}/{{item.Product.Link}}">
					<img ng-src="{{item.Product.DefaultImage.Url}}" width="50" />
                </a>
			</td>        
            <td>
				<b>{{item.Product.Title}}</b>
                <br />
                <small>REF: {{item.Product.Code}}</small>
            </td>
            <td>
				<span ng-show="item.ProductStockInfo != null && item.ProductStockInfo.AvailableStock > 0">In stock</span>
				<span ng-show="item.ProductStockInfo != null && item.ProductStockInfo.AvailableStock == 0">Not in stock</span>
            </td>
            <td>
				<s ng-show="item.OfferName != null"><price value="{{item.CatalogPrice.Value}}" class="text-right"></price><br /></s>
				<price value="{{item.SalePrice.Value}}" class="text-right"></price>
				<div ng-show="item.OfferName != null">{{item.OfferName}}</div>
            </td>
            <td>
				<input type="number" class="input-mini text-center" ng-model="item.Quantity" ng-change="cart.changeQuantity($index,item)" ui-keypress="{ enter: 'cart.changeQuantity($index,item)'}" />
            </td>
            <td>
				<price value="{{item.GrandTotal}}" class="text-right"></price>
            </td>
        </tr>
    </tbody>
</table>

<table class="table table-striped">
    <tr>
		<td rowspan="8">
			<div class="input-append">
				<input ng-model="couponCode" type="text" placeholder="Any Coupon ?" />
				<button type="submit" class="btn" ng-click="applyCoupon(couponCode)">Apply</button>
			</div>
			<span>Try FakeCoupon</span>
			<div ng-show="checkCouponProgressMessage != null">{{checkCouponProgressMessage}}</div>
			<div ng-show="couponError != null">{{couponError}}</div>
			<div ng-show="cart.DiscountList != null && cart.DiscountList.length > 0">
				<table class="table table-condensed">
					<thead>
						<tr>
							<td>&nbsp;</td>
							<td>Code</td>
							<td>Description</td>
							<td>Amount</td>
						</tr>
					</thead>
					<tbody>
						<tr ng-repeat="coupon in cart.DiscountList">
							<td><button class="btn" title="remove coupon" ng-click="cart.deleteCoupon(coupon)"><i class="icon-remove"></i></button></td>
							<td>{{coupon.Code}}</td>
							<td>{{coupon.DiscountReason}}</td>
							<td><price value="{{coupon.Discount}}"></price></td>
						</tr>
					</tbody>
				</table>
			</div>
		</td>
    </tr>
    <tr>
        <td colspan="3" >&nbsp;</td>
        <td>Order Subtotal :</td>
        <td><price value="{{cart.GrossTotal}}" class="text-right"></price></td>
    </tr>
	<tr>
		<td colspan="3">&nbsp;</td>
		<td>Discount Total :</td>
		<td><price value="{{cart.ItemsDiscountTotal * -1}}" class="text-right"></price></td>
	</tr>
	<tr>
		<td colspan="3">&nbsp;</td>
		<td>Order Total :</td>
		<td><price value="{{cart.Total - cart.DiscountTotal}}" class="text-right"></price></td>
	</tr>
     <tr>
		<td colspan="3">&nbsp;</td>
        <td>EcoTax : </td>
        <td><price value="{{cart.RecycleTotal}}" class="text-right"></price></td>
     </tr>
     <tr>
        <td colspan="3">&nbsp;</td>
		<td>Shipping :</td>
        <td ng-show="cart.ShippingFee.Total > 0"><price value="{{cart.ShippingFee.Total}}" class="text-right"></price></td>
		<td ng-show="cart.ShippingFee.Total == 0"><div class="text-right">Free</div></td>
    </tr>
     <tr>
        <td colspan="3">&nbsp;</td>
        <td>VAT : </td>
        <td><price value="{{cart.GrandTaxTotal}}" class="text-right"></price></td>
    </tr>
    <tr>
        <td colspan="3">&nbsp;</td>
        <td>Grand Total :</td>
        <td><h3><price value="{{cart.GrandTotalWithTax}}" class="text-right"></price></h3></td>
    </tr> 
</table>
        
<table class="table">
    <tr>
        <td>
			<a class="linkback button" href="#" >< continue <br />
		</td>
        <td>
			<div class="text-right">
				<a href="/checkout" class="btn btn-success btn-large">Checkout >></a>
			</div>
        </td>
    </tr>
</table> 
